package com.zzz.cloud.thrift;

import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientConfiguration;
import com.zzz.cloud.thrift.provider.NacosServerMetaDataProvider;
import com.zzz.cloud.thrift.provider.ServerInfoProvider;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@ConditionalOnProperty(name = "spring.thrift.server.nacos.discovery.enabled", havingValue = "true")
@AutoConfigureAfter({ThriftServerAutoConfiguration.class,
        NacosDiscoveryClientConfiguration.class})
@Import(ThriftServerAutoConfiguration.class)
public class ThriftServerNacosDiscoveryConfiguration {

    @Bean
    public NacosServerMetaDataProvider serverMetaDataProvider(ServerInfoProvider serverInfoProvider) {
        return new NacosServerMetaDataProvider(serverInfoProvider);
    }

}
